/**
 * 所有版权归 广西梧州 陈锦韬 所有
 *
 * @Title: SingleDetailHandler
 * @Package com.rx.uua.handler
 * @Description: 详情处理器
 * @author: 陈锦韬
 * @date: 2021\6\11 0011
 * @version V1.0
 * @Copyright: 2021 陈锦韬  All rights reserved.
 */
package com.rx.uua.handler;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.rx.core.anno.RxAlias;
import com.rx.core.base.RxBaseData;
import com.rx.core.dbase.RxBaseDbMust;
import com.rx.core.enm.HANDLER_TYPE;
import com.rx.core.handler.RxHandler;
import com.rx.core.handler.RxHandlerAfter;
import com.rx.core.handler.RxHandlerPrev;
import com.rx.uua.dao.UuaUserInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Arrays;
import java.util.List;

/**
 * @author: Administrator
 * @Description: 详情处理器
 * @date: 2021\6\11 0011
 */
@RxHandler
@Slf4j
public class SingleListHandler {

    @Autowired
    UuaUserInfoMapper mapper;


    @RxHandlerPrev(types= {HANDLER_TYPE.SINGLE_LIST},keys = {})
    @RxAlias("prehandle")
    public boolean prehandle(RxBaseData data){
        log.info("SingleListHandler操作前");
        return false;
    }
    @RxAlias("prehandle2")
    @RxHandlerPrev(types= {HANDLER_TYPE.SINGLE_LIST},order = 2,keys = {})
    public boolean prehandle2(RxBaseData data){
        log.info("SingleListHandler操作前2");
        data.skip(1);
        data.repeat(2);
        return false;
    }
    @RxHandlerPrev(types= {HANDLER_TYPE.SINGLE_LIST},order = 1,keys = {})
    @RxAlias("prehandle3")
    public boolean prehandle3(RxBaseData data){
        log.info("SingleListHandler操作前1");
        return false;
    }
    @RxHandlerAfter(types= {HANDLER_TYPE.SINGLE_LIST})
    public boolean afterhandle(RxBaseData data){
        log.info("SingleListHandler操作后");
        return false;
    }

    @RxHandler(types= {HANDLER_TYPE.SINGLE_LIST})
    public boolean handle(RxBaseData data){
        log.info("SingleListHandler覆盖");
        QueryWrapper queryWrapper = new QueryWrapper<>();
        RxBaseDbMust rxBaseDbMust = (RxBaseDbMust)data;
        queryWrapper.eq("bid",rxBaseDbMust.getBid());
        queryWrapper.in("valid", Arrays.asList(1,2));

        List<RxBaseData> result = mapper.selectList(queryWrapper);
        data.setResultData(result);
        return false;
    }
}
